package components.map
{
	import capricornus.components.window.Window;
	import capricornus.res.Image;
	
	import flash.display.DisplayObjectContainer;
	import flash.display.Shape;
	import flash.display.Sprite;
	
	public class MapView extends Window
	{
		public var back:Shape;
		
		public var imageBG:Image;
		public var backLayer:Sprite;
		public var backLayerMask:Shape;
		
		public var itemLayer:Sprite;
		public var gridLayer:Shape;
		public var searchLayer:Shape;
		public var gridMask:Shape;
		public var dragLayer:Sprite;
		
		public function MapView( owner:DisplayObjectContainer )
		{
			super( owner );
			init();
		}
		
		public function init():void
		{
			this.cacheAsBitmap = true;
			this.mouseChildren = false;
			
			back = new Shape();
			back.cacheAsBitmap = true;
			addChild( back );
			back.graphics.beginFill( 0xFFFFFF );
			back.graphics.drawRect( 0, 0, 1, 1 );
			back.graphics.endFill();
			
			imageBG = new Image();
			imageBG.mouseChildren = false;
			imageBG.mouseEnabled = false;
			imageBG.cacheAsBitmap = true;
			addChild( imageBG );
			
			backLayer = new Sprite();
			backLayer.alpha = 0.5;
			backLayer.cacheAsBitmap = true;
			backLayer.mouseEnabled = false;
			backLayer.mouseChildren = false;
			addChild( backLayer );
			
			backLayerMask = new Shape();
			backLayerMask.graphics.beginFill( 0xffffff );
			backLayerMask.graphics.drawRect( 0, 0, 1, 1 );
			backLayerMask.graphics.endFill();
//			addChild( backLayerMask );
//			backLayer.mask = backLayerMask;
			
			itemLayer = new Sprite();
			itemLayer.mouseEnabled = false;
			itemLayer.cacheAsBitmap = true;
			addChild( itemLayer );
			
			gridLayer = new Shape();
			gridLayer.alpha = 0.5;
			gridLayer.cacheAsBitmap = true;
			addChild( gridLayer );
			
			searchLayer = new Shape();
			addChild( searchLayer );
			
			gridMask = new Shape();
			gridMask.graphics.beginFill( 0xffffff );
			gridMask.graphics.drawRect( 0, 0, 1, 1 );
			gridMask.graphics.endFill();
//			addChild( gridMask );
//			gridLayer.mask = gridMask;
			
			dragLayer = new Sprite();
			dragLayer.cacheAsBitmap = true;
			dragLayer.mouseEnabled = false;
			addChild( dragLayer );
		}
	}
}